import {throttle} from "@/utils/throttle";

export default function (elButton) {
    elButton.props = {
        ...elButton.props,
        throttle: {
            type: [Number, String],
        },
    }
    elButton.methods = {
        ...elButton.methods,
        handleClick(evt) {
            if (this.throttle) {
                throttle((evt) => {
                    this.$emit('click', evt);
                }, this.throttle, () => this.$emit('trailing'))
            } else {
                this.$emit('click', evt);
            }
        }
    }
    return elButton
}
